package com.liy.cloud.base.rest;

import com.liy.cloud.base.entity.BaseTypePartEntity;
import com.liy.cloud.base.service.BaseTypePartService;
import com.das.framework.common.annotation.ActionPermission;
import com.das.framework.common.annotation.MethodPermission;
import com.das.framework.common.extvo.ResultVO;
import com.das.framework.common.web.controller.BaseCrudController;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Auther: libs
 * @Date: 2018/6/27 20:35
 * @Description: 部件种类-部件关联
 */
@RestController
@RequestMapping("/type/part")
@ActionPermission(code="BASE.TYPE_PART", description="部件种类-部件关联")
public class BaseTypePartRest extends BaseCrudController<BaseTypePartService, BaseTypePartEntity> {

    @Resource
    private BaseTypePartService baseTypePartService;

    @RequestMapping(
            value = {"/save"},
            method = {RequestMethod.POST}
    )
    @ResponseBody
    @MethodPermission(
            codes = {"INSERT"},
            description = "新增"
    )
    public ResultVO save(@RequestBody Map<String, Object> params) {
        try {

            List<BaseTypePartEntity> typePartList = (List<BaseTypePartEntity>) params.get("typePartList");
            String typeId = (String) params.get("typeId");
            this.baseTypePartService.save(typePartList, typeId);
            return new ResultVO(true, "保存成功", "200");
        } catch (Exception var4) {
            log.error(var4.getMessage(), var4);
            return new ResultVO(false, "新增时发生错误:" + var4.getMessage(), "500");
        }
    }

}
